(function(){"use strict";BX.namespace("BX.Landing.UI.Field");BX.Landing.UI.Field.DropdownInline=function(t){this.items="items"in t&&t.items?t.items:{};this.id=t.id?t.id:"";BX.Landing.UI.Field.BaseField.apply(this,arguments);this.setEventNamespace("BX.Landing.UI.Field.DropdownInline");this.subscribeFromOptions(BX.Landing.UI.Component.fetchEventsFromOptions(t));this.popup=null;this.input.addEventListener("click",this.onInputClick.bind(this));this.layout.classList.add("landing-ui-field-dropdown-inline");if(BX.type.isPlainObject(this.items)){var i=Object.keys(this.items);this.items=i.map((function(t){return{name:this.items[t],value:t}}),this)}if(this.items.length===0){this.items.push({});this.items[0].name="";this.items[0].value=""}this.input.innerText=this.items[0].name;this.input.dataset.value=this.items[0].value;this.setValue(this.content,this.options.skipInitialEvent)};BX.Landing.UI.Field.DropdownInline.prototype={constructor:BX.Landing.UI.Field.DropdownInline,__proto__:BX.Landing.UI.Field.BaseField.prototype,onInputClick:function(){if(!this.popup){this.popup=new BX.PopupMenuWindow({id:this.selector+"_dropdown_popup_"+this.id,bindElement:this.input,bindOptions:{forceBindPosition:true},targetContainer:this.contentRoot,items:this.items.map((function(t){return{text:t.name,onclick:function(){this.onItemClick(t)}.bind(this)}}),this)});if(!this.contentRoot){this.layout.appendChild(this.popup.popupWindow.popupContainer)}}this.popup.show();if(!this.contentRoot){var t=BX.pos(this.input,this.layout);this.popup.popupWindow.popupContainer.style.top=t.bottom+"px";this.popup.popupWindow.popupContainer.style.left=t.left+"px"}},closePopup:function(){if(this.popup){this.popup.close()}},onItemClick:function(t){this.input.innerText=t.name;this.input.dataset.value=t.value;this.popup.close();BX.fireEvent(this.input,"input");this.emit("onChange");this.emit("onItemClick")},getValue:function(){return typeof this.input.dataset.value!=="undefined"?this.input.dataset.value:this.items[0].value},setValue:function(t,i){this.items.forEach((function(n){if(t===n.value){this.input.innerText=n.name;this.input.dataset.value=n.value;if(!i){this.emit("onChange")}}}),this)},setItems:function(t){if(BX.type.isArray(t)){this.items=BX.clone(t);this.popup=null;this.input.innerText=this.items[0].name;this.input.dataset.value=this.items[0].value}}}})();
//# sourceMappingURL=dropdown_inline.map.js